import { ref } from "vue";
import { defineStore } from "pinia";
import { Container } from "typedi";
import { AuthService } from "../repositories/AuthService";
import type { AuthRole } from "../repositories/role/entity";

/**
 * 管理当前授权的角色
 */
export const useAuthRoleStore = defineStore("auth-role", () => {
  const authRoles = ref<AuthRole[]>();
  const authService = Container.get(AuthService);
  const refresh = async () => {
    authRoles.value = await authService.getAuthRoles();
  };
  return { authRoles, refresh };
});
